<template>
	<view class="list-big">
		<view class="list-weixin-top">
			<view class="list-weixin">
				<view>
					<image class="list-weixin-top-img" src="/static/tabBar/search.png" @tap="gotosearch"></image>
				</view>
				<view>
					<input class="list-weixin-top-tetx" type="text" placeholder="点击搜索..." >
				</view>
			</view>
			
		</view>
	
		
		<view class="list">
			<!-- 左边 -->
			<view class="">
				<scroll-view  scroll-y="true" class="list-left" style="height:38vh;color: #cd5a91;">
					<view v-for="(item,index) in leftdata" :key="item.id" class="left-item"  @click="selectit(item.id)">
						<view class="left-name" :class="item.id === theindex ?'f-active-color':''">
							{{item.title}}
						</view>
						
					</view>
				</scroll-view>
				<scroll-view  scroll-y="true" class="list-left" style="height:38vh">
					<view v-for="(item,index) in leftdata2" :key="item.id" class="left2-item"  @click="selectit_leftdata2(item.list2_leftid,index)">
						<view class="left-name" :class="index === theindex2 ?'f-active-color':''">
							{{item.title}}
						</view>
						<lines></lines>
					</view>
				</scroll-view>
			</view>
			<!-- 	右边 -->
			<view class="">
				<scroll-view scroll-y="true" class="list-right" style="height:38vh">
					<view class="right-list" v-for="(item,index) in getdata" :key="item.id" @click="golistcontent(item.id)">
						<view class="r-l-img">
							<image class="r-l-img" src="/static/img/list/u=1176438957,3886434511&fm=253&fmt=auto&app=138&f=JPEG.webp" mode="widthFix"></image>
						</view>
						<view class="r-l-r">
							<view class="r-l-t">
								{{item.title}}
							</view>
							<view class="r-l-c" >
								{{item.littlecontent}}
							</view>
							
							<view style="width: 100%; border: 1rpx solid rgba(49, 53, 62, .2);  ">
								
							</view>
						</view>
				
					</view>
				</scroll-view>
				<scroll-view scroll-y="true" class="list-right" style="height:38vh;margin: 0 20rpx;">
					<view style="display: flex;align-items: center;flex-wrap: wrap;">
						
						<view  v-for="(item,index) in list2_right" :key="index" style="margin: 5rpx 30rpx;" @tap="getvideo(item.videourl)">
							<view class="allimg_time"  >
								<image :src="baseurl+ item.imgrul" mode="aspectFill" style="width: 200rpx;height: 200rpx;overflow: hidden;"></image>
								<view class="timeback">
									{{ generateRandomTime() }}
								</view>
							</view>
							<view style="display: flex;align-items: center;justify-content: center;">
								<view class="pearsen">
									{{item.title}}
								</view>
							</view>
							
						</view>
					</view>
					
					
				</scroll-view>
			</view>
		</view>
		<tarbar currentPage="list"></tarbar>
	</view>
</template>

<script>
	import lines from "@/components/common/Lines.vue"
	import $http from '@/common/api/request.js'
	import tarbar from '@/common/tabbar.vue'
	export default {
		data() {
			return {
				getheight: 0,
				theindex:0,
				theindex2:0,
				getdata:[],
				leftdata:[],
				leftdata2:[],
				list2_right:[],
				baseurl:"https://zyc618.mynatapp.cc",
				videoimglist:[{id:0,imgurl:"../../static/img/list/1.jpg",title:"亲子探索"},
							{id:1,imgurl:"../../static/img/list/2.jpg",title:"亲子关系"},
							{id:2,imgurl:"../../static/img/list/3.jpg",title:"陪伴的力量"}
				]
			};
		},
		methods: {
			//获取右边数据列表
			getdatalist(){
				$http.request({
					url: "/listdata_r",
					method:"POST",
					data:{
						keyid:this.theindex
					}
				}).then((res) => {
					uni.showToast({
						title: "获取数据中...",
						icon: "none",
						mask: true,
						duration: 200,
						success: () => {
							
							this.getdata = res
						
						}
					})
				
				}).catch(() => {
					uni.showToast({
						title: "获取listdata_r数据失败",
						icon: "error",
						mask: true,
						duration: 2000
					})
				})
			},
			//点击跳转到搜索页面
			gotosearch() {
				uni.showToast({
					title:"开发维护中...",
					icon:"none"
				})
			},
			//获取左滚动窗的数据-leftdata
			getlistdata_l(){
				$http.request({
					url: "/listdata_l"
				}).then((res) => {
					uni.showToast({
						title: "获取数据中...",
						icon: "none",
						mask: true,
						duration: 500,
						success: () => {
							
							this.leftdata = res
						}
					})
				
				}).catch(() => {
					uni.showToast({
						title: "获取getlistdata_l数据失败",
						icon: "error",
						mask: true,
						duration: 2000
					})
				})
			},
			getgetleft2(){
				$http.request({
					url: "/save/getleft2"
				}).then((res) => {
					if(res.code == 200){
						
						this.leftdata2 = res.data.results
					}else{
						uni.showTabBar({
							title:"错误",
							icon:"none"
						})
					}
					
				
				}).catch(() => {
					uni.showToast({
						title: "获取getlistdata_l数据失败",
						icon: "error",
						mask: true,
						duration: 2000
					})
				})
			},
			selectit_leftdata2(index,theindex2){
				
				$http.request({
					url: "/save/getlist2_right",
					method:"POST",
					data:{
						id:index
					}
				}).then((res) => {
					this.list2_right = res.data.results;
					this.theindex2 = theindex2;
				}).catch(() => {
					uni.showToast({
						title: "失败",
						icon: "error"
					})
				})
			},
			
			//获取高度
			getClientHeight() {
				const res = uni.getSystemInfo();
				const system = res.platform;
				if (system === 'ios') {
					return 44 + res.statusBarHeight;
				} else if (system === 'android') {
					return 48 + res.statusBarHeight;
				} else {
					return 0
				}
			},
			selectit(index){
				this.theindex=index;
				this.getdatalist()
			},
			//前往内容详情页面:
			golistcontent(id){
				this.navigateTo({
					url:`/pages/listcontent/listcontent?indexid=${id}`
				})
			},
			getvideo(index){
				this.navigateTo({
					url:`/pages/videoshow/videoshow?videourl=${index}`
				})
			},
			generateRandomTime() {
			          // 生成两个随机数
			          const randomHour = this.getRandomInt(0, 23);
			          const randomMinute = this.getRandomInt(0, 59);
			
			          // 格式化为 "HH:MM" 格式
			          const formattedHour = ('0' + randomHour).slice(-2);
			          const formattedMinute = ('0' + randomMinute).slice(-2);
			
			          // 设置随机时间
			          return `${formattedHour}:${formattedMinute}`;
			        },
			        getRandomInt(min, max) {
			          min = Math.ceil(min);
			          max = Math.floor(max);
			          return Math.floor(Math.random() * (max - min + 1)) + min;
			        }
		},
		components: {
			lines,tarbar
		},
		onReady() {
			this.getdatalist();
			this.getlistdata_l();
			this.getgetleft2();
			this.selectit_leftdata2(1);
			uni.getSystemInfo({
				success: (res) => {
					this.getheight = res.windowHeight  -this.getClientHeight()
			
				}
			})	
		}
	}
</script>

<style lang="scss">
	scroll-view ::-webkit-scrollbar{
		display: none !important;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		background:transparent;
	}
	.list-big {
		
		.list-weixin-top {

			// align-items: center;
			padding: 5rpx 20rpx;
			
			background-color: #f7f7f7;

			.list-weixin {
				display: flex;
				justify-content: center;

				.list-weixin-top-img {
					width: 40rpx;
					height: 40rpx;
				}

				.list-weixin-top-tetx {
					width: 450rpx;
					height: 100%;
					font-size: 36rpx;
					margin-left: 30rpx;
				}

			}

		}

		.list {
			display: flex;
			.list-left {
				display: flex;
				justify-content: center;
				width: 150rpx;
				.left-name {
					padding: 0rpx 5rpx;
					height: 40px;
					display: flex;
					text-align: center;
					align-items: center;
					font-size: 28rpx;
					border-bottom: 1rpx solid #FFFFFF;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					overflow: hidden;
					-webkit-line-clamp: 2; /* 控制显示的行数 */
					line-height: 40px;
					
				}
				.f-active-color{
					background-color: #9c446e;
					color: #f7f7f7;
				}
			}

			.list-right {
				margin-bottom:80rpx ;
				.right-list {
					display: flex;
					
					position: relative;
					justify-content: space-around;
					margin: 15rpx 10rpx;
					.r-l-img{
						width: 200rpx;
						
					}
					.r-l-r{
						margin: 10rpx 0;
						.r-l-t{
							font-size: 30rpx;
							font-weight: 800;
							 display: -webkit-box;
							  -webkit-line-clamp: 1;
							  -webkit-box-orient: vertical;
							  overflow: hidden;
						}
						.r-l-c{
							font-size: 24rpx;
							margin: 15rpx 0;
							display: -webkit-box;
							 -webkit-line-clamp: 3;
							 -webkit-box-orient: vertical;
							 overflow: hidden;
						}
						.r-l-time{
							font-size: 20rpx;
						}
					}

					
				}
			}
		}
	}
	.allimg_time{
		position: relative;
		width: 200rpx;
	}
		.timeback{
			background-color: rgba(0, 0, 0, 0.5);
			color: #f7f7f7;
			font-size: 28rpx;
			position: absolute;
			bottom: 0;
			right: 0;
		}
		.pearsen{
			display: -webkit-box;
			 -webkit-line-clamp: 1;
			 -webkit-box-orient: vertical;
			 overflow: hidden;
			 width: 200rpx;
			 color: #9c446e;
			 font-size: $uni-font-size-sm;
			 text-align: center;
		}
</style>